package cn.bugstack.domain.order.model.aggregate;


/**
 * @author 丨一
 * @version 1.0
 * @title CreateOrderAggregate
 * @description:
 * @date 2024/11/12 20:02
 */

import cn.bugstack.domain.order.model.entity.OrderEntity;
import cn.bugstack.domain.order.model.entity.ProductEntity;
import cn.bugstack.domain.order.model.valueOBJ.OrderStatusVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;

import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CreateOrderAggregate {


    private String userId;
    
    private ProductEntity productEntity;
    
    private OrderEntity orderEntity;

    public static OrderEntity buildOrderEntity(String productId, String productName) {
        return OrderEntity.builder()
                .orderId(RandomStringUtils.randomNumeric(14))
                .productId(productId)
                .productName(productName)
                .orderStatusVO(OrderStatusVO.CREATE)
                .orderTime(new Date())
                .build();
    }
    
    
}
